package com.scpii.universal.pns.entity;

import java.util.Date;
import java.util.List;

import net.sf.json.JSONArray;

import org.apache.commons.lang.StringUtils;

import com.scpii.universal.pns.dto.BodyDto;

/**
 * PnsMessages entity. @author MyEclipse Persistence Tools
 */

public class PnsMessages implements java.io.Serializable {

	// Fields

	/**
	 * 
	 */
	private static final long serialVersionUID = -1946714314789270558L;

	private Long id;
	private Long appId;
	private String title;
	private String icon;
	private String summary;
	private String body;
	private Date startTime;
	private Date expireTime;
	private Date createTime;
	private Integer messageStatus;
	private String searchCondition;

	private Integer viewCount;

	private Integer sendCount;

	private Integer pushCount;

	private Integer flag;

	// Constructors

	/** default constructor */
	public PnsMessages() {
	}

	/** minimal constructor */
	public PnsMessages(Long appId) {
		this.appId = appId;
	}

	/** full constructor */
	public PnsMessages(Long appId, String title, String icon, String summary,
			String body, Date startTime, Date expireTime, Date createTime,
			Integer messageStatus) {
		this.appId = appId;
		this.title = title;
		this.icon = icon;
		this.summary = summary;
		this.body = body;
		this.startTime = startTime;
		this.expireTime = expireTime;
		this.createTime = createTime;
		this.messageStatus = messageStatus;
	}

	public Long getId() {
		return this.id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public Long getAppId() {
		return this.appId;
	}

	public void setAppId(Long appId) {
		this.appId = appId;
	}

	public String getTitle() {
		return this.title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public String getIcon() {
		return this.icon;
	}

	public void setIcon(String icon) {
		this.icon = icon;
	}

	public String getSummary() {
		return this.summary;
	}

	public void setSummary(String summary) {
		this.summary = summary;
	}

	public String getBody() {
		return this.body;
	}

	public void setBody(String body) {
		this.body = body;
	}

	public Date getStartTime() {
		return this.startTime;
	}

	public void setStartTime(Date startTime) {
		this.startTime = startTime;
	}

	public Date getExpireTime() {
		return this.expireTime;
	}

	public void setExpireTime(Date expireTime) {
		this.expireTime = expireTime;
	}

	public Date getCreateTime() {
		return this.createTime;
	}

	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}

	public Integer getMessageStatus() {
		return this.messageStatus;
	}

	public void setMessageStatus(Integer messageStatus) {
		this.messageStatus = messageStatus;
	}

	public Integer getFlag() {
		return flag;
	}

	public void setFlag(Integer flag) {
		this.flag = flag;
	}

	public Integer getViewCount() {
		return viewCount;
	}

	public void setViewCount(Integer viewCount) {
		this.viewCount = viewCount;
	}

	public String getSearchCondition() {
		return searchCondition;
	}

	public void setSearchCondition(String searchCondition) {
		this.searchCondition = searchCondition;
	}

	public Integer getSendCount() {
		return sendCount;
	}

	public void setSendCount(Integer sendCount) {
		this.sendCount = sendCount;
	}

	public Integer getPushCount() {
		return pushCount;
	}

	public void setPushCount(Integer pushCount) {
		this.pushCount = pushCount;
	}

	@SuppressWarnings("unchecked")
	public List<BodyDto> getBodyDtos() {
		if (!StringUtils.isBlank(body)) {
			JSONArray jsonArray = JSONArray.fromObject(body);
			return JSONArray.toList(jsonArray, BodyDto.class);
		} else {
			return null;
		}
	}

}